cmake_minimum_required(VERSION 3.10)
project(MyProject)

# 设置编译选项
# 必须指定C++17，否则无法连接redis++
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


#添加可执行文件 server
add_executable(Sever
    src/server/Acceptor.cpp
    src/server/Condition.cpp
    src/server/EventLoop.cpp
    src/server/InetAddress.cpp
    src/server/main.cpp
    src/server/MutexLock.cpp
    src/server/ProtocolParser.cpp
    src/server/SearchEngineServer.cpp
    src/server/Socket.cpp
    src/server/SocketIO.cpp
    src/server/TaskQueue.cpp
    src/server/TcpConnection.cpp
    src/server/TcpServer.cpp
    src/server/Thread.cpp
    src/server/ThreadPool.cpp
    src/WebPageQuery.cpp
    src/Mylogger.cpp
    src/Dict/Chcommander.cpp
    src/CacheManager.cpp
    src/LRUCache.cpp
    #src/Dict/ChDictionary.cpp
    #src/Dict/dictionary.cpp
    src/Dict/EditDistance.cpp
    src/Dict/En_distance.cpp
    src/Dict/EnRecommander.cpp
)

# 添加头文件搜索路径
target_include_directories(Sever PRIVATE
    include
)

# 链接 pthread 库
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(Sever PRIVATE Threads::Threads)
#链接redis—plus-plus
#find_package(hiredis REQUIRED)
#find_package(redis++ REQUIRED)
target_link_libraries(Sever PRIVATE hiredis)
target_link_libraries(Sever PRIVATE redis++)


# 链接log4cpp库
target_link_libraries(Sever PRIVATE log4cpp)

# 指定安装规则
install(TARGETS Sever DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)


#添加可执行文件
add_executable(mainPageLib
    src/PageLib/DirScanner.cpp
    src/PageLib/mainPageLib.cpp
    src/PageLib/PageLib.cpp
    src/PageLib/PageLibPreprocess.cpp
    src/PageLib/SimHash.cpp
    src/Configuration.cpp
    src/SplitTool.cpp
)

# 添加头文件搜索路径
target_include_directories(mainPageLib PRIVATE
    include/PageLib
    include
)

# 链接log4cpp库
target_link_libraries(mainPageLib PRIVATE log4cpp)

# 链接 tinyxml2 库
target_link_libraries(mainPageLib PRIVATE tinyxml2)
# 指定安装规则
install(TARGETS mainPageLib DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)

# 添加可执行文件
add_executable(ChDictionary
    src/Dict/ChDictionary.cpp
)

#添加头文件搜索路径
target_include_directories(ChDictionary PRIVATE
    include/Dict
    include
)

#指定安装规则
install(TARGETS ChDictionary DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)


# 添加可执行文件
add_executable(EnDictionary
    src/Dict/dictionary.cpp
)

#添加头文件搜索路径
target_include_directories(ChDictionary PRIVATE
    include/Dict
    include
)

#指定安装规则
install(TARGETS EnDictionary DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin)